<%@ page language="java" import="com.util.StringFinal" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="../../bootstrap-3.3.7/dist/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../../bootstrap-3.3.7/dist/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="../../css/index.css" />
<link rel="stylesheet" type="text/css" href="../../css/personal.css" />
<link rel="stylesheet" type="text/css" href="../../css/background.css" />
<link rel="stylesheet" type="text/css" href="../../css/upload/fileinput.css" />

<link href="../../css/bootstrap-datetimepicker.min.css" rel="stylesheet" />

<script type="text/javascript" src="../../bootstrap-3.3.7/dist/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap-3.3.7/dist/js/bootstrap.js"></script>
<script type="text/javascript" src="../../js/upload/fileinput.js"></script>
<script type="text/javascript" src="../../js/upload/zh.js"></script>
<script type="text/javascript" src="../../js/login/jquery.form.min.js"></script>
<script type="text/javascript" src="../../js/dynamic.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="../../bootstrap-3.3.7/docs/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<script src="../../js/moment-with-locales.js"></script>
<script src="../../js/bootstrap-datetimepicker.min.js"></script>
<script src="../../js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script type="text/javascript" src="../../js/wordcontrol.js"></script>
</head>
<body>
	<form class="form-horizontal" id="fm"  enctype="application/x-www-form-urlencoded" method="post">
		<h4 class="heading">修改知识</h4>
		<div class="myline"></div>
		<div class="col-md-10">
			<div class="form-group">
				<input type="text" id="info_id" hidden="true" value="${info.info_id}" name="info_id">
				<input type="text" id="first_class" hidden="true" value="${info.first_class}" name="first_class"> 
				<input type="text" id="info_url" hidden="true" name="info_url"  value="${info.info_url}">
				<input type="text" id="info_level" hidden="true" name="info_level" value="${info.info_level}" >
				<input type="text" id="info_status" hidden="true" name="info_status"  value="${info.info_status}">
				<br> <label class="col-md-2 control-label">篇名:</label>
				<div class="col-md-8">
					<input id="info_name" type="text" class="form-control" name="info_name" value="${info.info_name}" >
				</div>
				<div style="float: left">
					<span style="color: red;">必填</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">作者:</label>
				<div class="col-md-9">
					<input id="info_author" type="text" class="form-control" name="info_author" value="${info.info_author}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">作者单位:</label>
				<div class="col-md-9">
					<input id="info_company" type="text" class="form-control" name="info_company" value="${info.info_company}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">关键词:</label>
				<div class="col-md-8">
					<input id="info_keyword" type="text" class="form-control" name="info_keyword" value="${info.info_keyword}">
				</div>
				<div style="float: left">
					<span style="color: red;">必填</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">发布部门:</label>
				<div class="col-md-9">
					<input id="info_bm" type="text" class="form-control" name="info_bm" value="${info.info_bm}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">文献来源:</label>
				<div class="col-md-9">
					<input id="info_source" type="text" class="form-control" name="info_source" value="${info.info_source}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">发布日期:</label>
				<div class="col-md-9">
					<input id="info_time" type="text" class="form-control" name="info_time" value="${info.info_time}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">文号:</label>
				<div class="col-md-7">
					<input id="info_wh" type="text" class="form-control" name="info_wh" value="${info.info_wh}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">摘要:</label>
				<div class="col-md-9">
					<textarea id="info_abstract" name="info_abstract" onKeyUp="ControlWordCount(&quot;content&quot;,&quot;count&quot;,<%=StringFinal.system_message_length%>)"  cols="38" rows="6" class="form-control">${info.info_abstract}</textarea>
				</div>
				<div style="float: left">
					<span style="color: red;">必填</span>
				</div>
				<p style="float: right; margin-top: 5px">
					你还可以输入<span id="count"><%=StringFinal.system_message_length%></span>个字
				</p>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">下载:</label>
				<div class="col-md-10" style="margin-top: 8px;">
					<a href="javascript:download()"  onclick=""><span id="download_name" class="text-primary" style="font-weight: bold"></span></a>
				</div>
			</div>
			<div class="form-group">
				<label class="col-md-2 control-label">提示:</label>
				<div class="col-md-10">
			      <label class="radio-inline">
			        <input type="radio" value="no" name="modify" checked="true">下载的知识文件内容没有修改
			      </label>
			      <label class="radio-inline">
			        <input type="radio" value="yes" name="modify">下载的知识文件内容进行了修改
			      </label>
			     </div>
   			 </div>
			<div class="form-group" id="uploaddiv" hidden>
				<label class="col-md-2 control-label">重新上传:</label>
				<div class="col-md-7">
					<input id="fileinput" name="fileinput" type="file">
				</div>
			</div>
		</div>
	</form>
	<div class="row">
		<div class="col-md-4"></div>
		<div class="col-md-6">
			<button type="button" class="btn  btn-info" id="checkAgree" onclick="submitForm()">确认修改</button>
		</div>
	</div>

</body>




<script>
	var urL="../information/updateCheckInfo";
	function download() {
		var filename=$('#info_url').val();
		var infoid= $('#info_id').val();
		var status ="通过";
		var url = encodeURI("../information/p_downloadn?filename=" + filename+"&infoid="+infoid+"&status="+status);
		window.location.href =url;
	}
	$(function() {
		/* 	//获取rootku下拉框中的值
		KuBind("ku1", 1, "");
		//根据rootku中的值初始化相应子库
		dynamicKu("addku", $("#ku1").val());
		//根据rootku中的值初始化下面的标签下拉框
		TagBind("tag", $("#ku1").val());
		//绑定事件 */
		
		var url=$('#info_url').val();
		var names=url.split("_", 2);
		$('#download_name').html(names[names.length-1]);
		fileinput();
		datetime();

		$("input[type='radio']").click(function(){
			//不上传
			if($("input[type='radio']:checked").val()=="no")
			{
				$("#fm").attr("entype","application/x-www-form-urlencoded");
				urL="../information/updateCheckInfo";
				$("#uploaddiv").hide();
			}
			//上传文件
			else
			{
				$("#fm").attr("entype","multipart/form-data");
				urL="../information/updatefileCheckInfo";
				$("#uploaddiv").show();
			}
			
		});
	});
	
	function datetime() {
		$('#datetime').datetimepicker({
			language : 'zh-CN',//显示中文
			format : 'yyyy-mm-dd',//显示格式
			minView : "month",//设置只显示到月份
			initialDate : new Date(),
			autoclose : true,//选中自动关闭
			todayBtn : true,//显示今日按钮
			locale : moment.locale('zh-cn')
		});

	}
	function fileinput() {
		$("#fileinput").fileinput({
			browseLabel : '选择文件',
			language : 'zh', //设置语言
			showPreview : false,
			allowedFileExtensions : ['doc', 'pdf', 'docx'],//接收的文件后缀
			showUpload : false, //是否显示上传按钮
			showCaption : true,//是否显示标题
			browseClass : "btn btn-primary", //按钮样式  
			uploadAsync : false, //默认异步上传
			maxFileSize : 1024,//单位为kb，如果为0表示不限制文件大小
			minFileCount : 0,
			maxFileCount : 20, //表示允许同时上传的最大文件个数
			enctype : 'multipart/form-data',
			validateInitialCount : true,
			msgFilesTooMany : "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
			language : 'zh',
		});
	}
	function submitForm(){
		var name=$('#info_name').val();
		var keyword=$('#info_keyword').val();
		var infoabs=$("#info_abstract").val();
		if(name ==null ||name==""||keyword==null||keyword==""||infoabs==null||infoabs=="")
		{
			alert("存在未输入的必填项");
			return;
		}
	    	$("#checkAgree").attr("disabled",true);
			if ($("input[type='radio']:checked").val() == "yes") {
				if ($("#fileinput").val() =="" ||$("#fileinput").val() == null) {
					alert("请输入文件");
					$("#checkAgree").attr("disabled", false);
					return;
				}
			}
			
			$("#fm").ajaxSubmit({
				url:urL,
				success:function(result){
					if(result==1){
						alert("修改成功");
						$("#refresh").load("../information/getInfoManageview");
					}
					else{
					    alert("修改失败");
						$("#checkAgree").attr("disabled",false);
					}
					
				
				}
			});
		
	}
	
	
</script>
</html>